<cfoutput>
<!---HTML header, css links, js links, and page title--->
#BASE.htmlHeader("", "css/style.css", "Elder's Program - Reports")#
<!---HTML header, css links, js links, and page title---> 
         
    <h2>Medicaid Billing - #url.BillingType#</h2>    
    
    <!---MedicaidBilling is set in showreport---> 
        
    <cfquery dbtype="query" name="ReportCustomerName">
        SELECT DISTINCT CustomerName, DOB, SignatureCaseNumber
        FROM MedicaidBilling
    </cfquery>
    
    <cfset customerArray = ArrayNew(1) />
    
    <cfloop query="ReportCustomerName">
    	<cfif ReportCustomerName.SignatureCaseNumber NEQ "">
	    	<cfset customerString = "" & ReportCustomerName.CustomerName & ";" & ReportCustomerName.DOB & ";" & ReportCustomerName.SignatureCaseNumber  />
        <cfelse>
        	<cfset customerString = "" & ReportCustomerName.CustomerName & ";" & ReportCustomerName.DOB & ";" & " "  />
        </cfif>
    	<Cfset ArrayAppend(customerArray, customerString) />
    </cfloop>

    <table>
        <tbody>
        	<cfloop from="1" to="#ArrayLen(customerArray)#" index="name" >
            	<cfquery dbtype="query" name="CustomerBilling">
                	SELECT * 
                    FROM MedicaidBilling
                    WHERE MedicaidBilling.CustomerName = <cfqueryparam cfsqltype="cf_sql_varchar" value="#ListGetAt(customerArray[name], 1, ';')#" />
                </cfquery>

                <tr>
                	<td><strong>Customer:</strong> <cftry>#ListGetAt(customerArray[name], 1, ";")#<cfcatch type="any">None</cfcatch></cftry></td>
                    <td><strong>DOB:</strong> <cftry>#DateFormat(ListGetAt(customerArray[name], 2, ";"), 'mm/dd/yyyy')#<cfcatch type="any">None</cfcatch></cftry></td>
                    <td><strong>Signature Case No.: <cftry></strong>#ListGetAt(customerArray[name], 3, ";")#<cfcatch type="any">None</cfcatch></cftry></td>
                </tr>
                <tr>
                	<td colspan="3">
                    	<table width="100%">
                        	<tbody>
                            	<tr>
                                	<td><strong>Service</strong></td>
                                    <td><strong>Date of Service</strong></td>
                                    <td><strong>Units Provided</strong></td>
                                    <td><strong>Provider Name</strong></td>
                                </tr>
                            	<cfloop query="CustomerBilling">
                                    <tr>
                                        <td>#url.BillingType#</td>
                                        <td>#DateFormat(CustomerBilling.NoteDate, 'mm/dd/yyyy')#</td>
                                        <td>#CustomerBilling.TotalUnits#</td>
                                        <td>#CustomerBilling.ProviderName#</td>
                                    </tr>
                                </cfloop>
                            </tbody>
                        </table>
                    </td>
                </tr>
            </cfloop>
        </tbody>
    </table>
    
<!---HTML footer, closes html and body tags.  Any footer info goes here--->
#BASE.htmlFooter()#
<!---HTML footer, closes html and body tags.  Any footer info goes here--->
</cfoutput>